import {inputComponents, selectComponents, layoutComponents, formConf} from './config'

/**
 * 定义不同类型的控件
 */
export default class FromItems {

    dataItem = {}

    constructor(item) {
        this.dataItem = item
    }

    /**
     * 接受不同类型的tag
     * @param tag
     */
    swByTag(tag) {
        let html = "";
        switch (tag) {
            case "el-input":
                html = this.inputTag()
                break
            case "el-input-number":
                html = this.inputNumberTag()
                break
        }
        return html;
    }

    inputTag() {
        let dataItem = this.dataItem;
        return`<el-form-item  :label="${dataItem.label}" :prop="${formConf.formModel}.${dataItem.vModel}">
     <el-input v-model="${formConf.formModel}.${dataItem.vModel}"  type="${dataItem.tagIcon}" placeholder="${dataItem.placeholder}"
                     show-password="${dataItem.showPassword}"
                     clearable="${dataItem.clearable}"
                     style="${dataItem.style}"
                     show-word-limit="${dataItem.showWordLimit}"/>
       </el-form-item>`
}
    inputNumberTag() {
        let dataItem = this.dataItem;
        return`<el-form-item  :label="${dataItem.label}" :prop="${formConf.formModel}.${dataItem.vModel}">
                    <el-input-number v-model="${formConf.formModel}.${dataItem.vModel}"  type="${dataItem.tagIcon}" placeholder="${dataItem.placeholder}"
                     :min="${dataItem.min}" :max="${dataItem.max}"
                     style="${dataItem.style}"/>
         </el-form-item>`
    }
}
